Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Add Rebasable token to Optimism #58

Draft
wants to merge 65 commits into
base: main
Choose a base branch
from

Conversation

kovalgek
Copy link
Contributor

@kovalgek kovalgek commented Nov 4, 2023

WHAT

Implement a new rebasable token on Optimism

HOW

  • add new token
  • change L1 and L2 bridges to support new token flows.
  • add token rate oracle for storing rate on L2
  • add token updater for emergency flow
    Detailed schemes and explanation you can find here https://hackmd.io/@lido/ryKP1ssm6

TODO

  • Rebasable Token
    • implementation
    • unit tests
  • Token Rate Oracle
    • implementation
    • unit tests
  • L1Bridge
    • implementation
    • unit tests
  • L2Bridge
    • implementation
    • unit tests
  • Deploy scripts
  • Integration tests
  • E2E tests
  • gas tests

contracts/token/ERC20Rebasable.sol Fixed Show fixed Hide fixed
contracts/token/ERC20Rebasable.sol Fixed Show fixed Hide fixed
contracts/optimism/L1ERC20TokenBridge.sol Outdated Show resolved Hide resolved
contracts/optimism/L1ERC20TokenBridge.sol Outdated Show resolved Hide resolved
contracts/optimism/TokenRateOracle.sol Outdated Show resolved Hide resolved
contracts/optimism/TokenRateOracle.sol Outdated Show resolved Hide resolved
contracts/optimism/TokenRateOracle.sol Outdated Show resolved Hide resolved
contracts/optimism/TokenRateOracle.sol Outdated Show resolved Hide resolved
contracts/optimism/TokenRateOracle.sol Outdated Show resolved Hide resolved
contracts/optimism/TokenRateOracle.sol Outdated Show resolved Hide resolved
contracts/optimism/TokenRateOracle.sol Outdated Show resolved Hide resolved
contracts/optimism/TokenRateOracle.sol Outdated Show resolved Hide resolved
@kovalgek kovalgek changed the title Add Rebasable token [WIP] Add Rebasable token to Optimism Jan 9, 2024
@kovalgek kovalgek requested a review from arwer13 January 10, 2024 11:15
) external {
for (uint256 obIndex = 0; obIndex < observers.length; obIndex++) {
try ITokenRatePusher(observers[obIndex]).pushTokenRate() {}
catch (bytes memory lowLevelRevertData) {

Check warning

Code scanning / Slither

Uninitialized local variables Medium

Comment on lines 96 to 98
function observersLength() public view returns (uint256) {
return observers.length;
}

Check warning

Code scanning / Slither

Public function that could be declared external Warning

observersLength() should be declared external:
- TokenRateNotifier.observersLength()
.env.example Outdated Show resolved Hide resolved
Copy link
Contributor

@TheDZhon TheDZhon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👀

.env.example Outdated Show resolved Hide resolved
.env.example Outdated Show resolved Hide resolved
.env.example Outdated Show resolved Hide resolved
.env.example Show resolved Hide resolved
.env.example Outdated Show resolved Hide resolved
contracts/optimism/L1ERC20TokenBridge.sol Outdated Show resolved Hide resolved
contracts/optimism/L1ERC20TokenBridge.sol Outdated Show resolved Hide resolved
contracts/optimism/L1ERC20TokenBridge.sol Outdated Show resolved Hide resolved
contracts/optimism/L1ERC20TokenBridge.sol Outdated Show resolved Hide resolved
contracts/optimism/L1ERC20TokenBridge.sol Outdated Show resolved Hide resolved
Copy link
Contributor

@TheDZhon TheDZhon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Second pass 👀

contracts/lido/TokenRateNotifier.sol Show resolved Hide resolved
contracts/lido/TokenRateNotifier.sol Outdated Show resolved Hide resolved
contracts/lido/TokenRateNotifier.sol Show resolved Hide resolved
contracts/lido/TokenRateNotifier.sol Show resolved Hide resolved
contracts/token/ERC20Permit.sol Outdated Show resolved Hide resolved
contracts/token/ERC20Permit.sol Outdated Show resolved Hide resolved
contracts/token/ERC20Permit.sol Outdated Show resolved Hide resolved
contracts/token/ERC20Rebasable.sol Outdated Show resolved Hide resolved
contracts/token/ERC20Rebasable.sol Outdated Show resolved Hide resolved
Copy link
Contributor

@TheDZhon TheDZhon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

contracts/token/ERC20Rebasable.sol Outdated Show resolved Hide resolved
contracts/token/ERC20Rebasable.sol Outdated Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add a note about deployment behind proxies for this and other relevant contracts
It would be great to have it as a part of the spec

WRAPPED_TOKEN = IERC20(wrappedToken_);
TOKEN_RATE_ORACLE = ITokenRateOracle(tokenRateOracle_);
BRIDGE = bridge_;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ please consider petrifying implementations with __disable_Initializers() or whatever

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://forum.openzeppelin.com/t/what-does-disableinitializers-function-mean/28730

relevant mostly not for this contract, but for others (bridges, might be applicable for TokenRateOracle, whatever)

contracts/token/ERC20Rebasable.sol Outdated Show resolved Hide resolved
contracts/token/ERC20RebasablePermit.sol Outdated Show resolved Hide resolved
contracts/token/UnstructuredRefStorage.sol Outdated Show resolved Hide resolved
contracts/token/interfaces/ITokenRateOracle.sol Outdated Show resolved Hide resolved
contracts/token/interfaces/IERC20BridgedShares.sol Outdated Show resolved Hide resolved
package.json Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants